/*
 * File Name:               Capsule3DTester.cs
 * 
 * Description:             普通类
 * Author:                  lisiyu <576603306@qq.com>

 * Create Date:             2017/06/20
 */

using UnityEngine;

public class Capsule3DTester : MonoBehaviour
{
    public Transform Point01;
    public Transform Point02;
    public XNumber Radius;

    public Transform SegmentPos01;
    public Transform SegmentPos02;

    private void Update()
    {
        var capsule = new XCapsule3D((XVector3)Point01.position, (XVector3)Point02.position, Radius);
        capsule.draw();
        DebugExtension.DebugArrow(SegmentPos01.position, SegmentPos02.position - SegmentPos01.position);
        XVector3 crossPoint = XVector3.zero;
        var segPos01 = (XVector3)SegmentPos01.position;
        var segPos02 = (XVector3)SegmentPos02.position;

        //ProfilerTimer.begin();
        //for (int i = 0; i < 1000; i++)
        //{
        //    capsule.cross(segPos01, segPos02, out crossPoint);
        //}
        //ProfilerTimer.end("capsule");

        XCapsule3D.CrossData crossData;
        if(capsule.cross(segPos01, segPos02, out crossData))
        {
            DebugExtension.DebugPoint(crossData.CrossPos, Color.red);
            DebugExtension.DebugArrow(crossData.CrossPos, crossData.CrossNormal, Color.red);
        }
    }
}
